require 'pan/color'

class ColorSample < Pan::Component
  def initialize(colors_to_show=10)
    @colors_to_show = colors_to_show
  end
  
  def render_on(html)
    colors = (1..@colors_to_show).to_a.map{|ea| Pan::Color.random_nice()}
    html.table("border"=>"1") {
      html.tr {
        html.th { html.text("Color") }
        html.th { html.text("Saturation") }
        html.th { html.text("Luminance") }
      }
      colors.sort.each do |color|
        html.tr {
          html.td("bgcolor"=>color.to_html) { html.text("#{color.to_html}") }
          html.td { html.text(color.saturation) }
          html.td { html.text(color.luminance) }
        }
      end
    }
  end
end

